nolora = "results/B_post_nolora.txt"  # 0.0008300943280124071 7649
sum_file = "results/B_post_sum.txt"  # Final 0.016387913427135865 7582
last_file = "results/B_post_last.txt"  # Final 0.016320 6422

with open(nolora, "r") as file:
    line = file.readline()
    row = 0
    max_d_m, max_row = - float("inf"), 0
    while line:
        # 开启读取数据模式
        if line.startswith("Semantic Segmentation mIoU:"):
            pre, num = line.split(":")
            seg = float(num)
            norm = 0.0
            sal = 0.0
            human = 0.0
            line = file.readline()  # 读取下一行
            row += 1
            while line and not (norm and sal and human):
                if line.startswith("rmse:"):
                    pre, num = line.split(":")
                    norm = float(num)
                if line.startswith("mIoU:"):
                    pre, num = line.split(":")
                    sal = float(num)
                if line.startswith("Human Parts mIoU"):
                    pre, num = line.split(":")
                    human = float(num)
                line = file.readline()
                row += 1

            base_seg = 67.21
            d_seg = seg - base_seg
            base_sal = 62.35
            d_sal = sal - base_sal
            base_norm = 17.97
            d_norm = base_norm - norm
            base_human = 61.93
            d_human = human - base_human
            d_m = (d_seg / base_seg + d_sal / base_sal + d_norm / base_norm
                   + d_human / base_human) / 4

            if d_m > max_d_m:
                max_d_m = d_m
                max_row = row

        line = file.readline()
        row += 1

print(f"max DelatM:{max_d_m} in line {max_row}")
